program ProjecX;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  Summator = class
    n: integer;
    procedure sum;
  end;

  SmartSummator = class (Summator)
    n: integer;
    procedure sum;
  end;


{ SmartSummator }

procedure SmartSummator.sum;
var t: real;
begin
 t:=n*(n+1)/2;
 Writeln(t:0:0);
end;

procedure Summator.sum;
var i,t:integer;
begin
 t:=0;
 for i:=1 to n do
   t:=t+i;
 writeln (t);
end;

var
  a:SmartSummator;
  b:Summator;
  n: integer;
begin
  a:=SmartSummator.Create;
  b:=Summator.Create;
  Readln (n);
  a.n:=n;
  b.n:=n;
  a.sum;
  b.sum;
  readln;
end.
 